package com.general.template.realm;

import com.general.template.exception.GeneralException;
import com.general.template.token.UsernamePasswordToken;
import com.general.template.enums.ResultEnum;
import com.general.template.enums.StateEnum;
import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;

/**
 * @Author: 杰哥
 * @Description:
 **/

public class AdminRealm extends AuthorizingRealm {

    @Override
    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
        return new SimpleAuthorizationInfo();
    }

    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
        com.general.template.token.UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken;
        int state = token.getState();
        String username = String.valueOf(token.getUsername());
        String password = String.valueOf(token.getPassword());
        //登陆认证逻辑自行编写
        if (state == StateEnum.ADMIN.getCode()) {

        } else {

        }
        return new SimpleAuthenticationInfo();
    }
}
